const spinetest = require('./spinetest.js');

Page({
    data() {
        animationData: {}
    },
    onShow() {
        console.log('index onLoad')
        const query = wx.createSelectorQuery()
        query.select('#mycanvas').fields({node: true, size: true}).exec((res) => {
            console.log(res)
            const canvas = res[0].node
            console.log('这里')
            this._render(canvas)
        })
    },
    dashboardTip() {
      console.log('dashboardTip')
    },
    _render(canvas) {
        wx.showToast({
            title: 'canvas',
            icon: 'success',
            duration: 2000
        })
        console.log(canvas)
        const gl = canvas.getContext('webgl', { alpha: true })
        if (!gl) {
            console.error('gl init failed', gl)
            return
        }

        spinetest.init(canvas, gl);
    }
})
